package xyz.robinbingo.leetcode.a20.b05.c19;

public class Solution {
    public boolean validPalindrome(String s) {
        return ps(s, 0);
    }

    private boolean ps(String s, int count) {
        if (s == null || s.length() == 0) {
            return false;
        }
        int i = 0, j = s.length() - 1;
        while (i <= j) {
            char c = s.charAt(i);
            char c1 = s.charAt(j);
            if (c == c1) {
                i++;
                j--;
            } else {
                if (count == 0) {
                    count++;
                    return ps(s.substring(i, j), count) || ps(s.substring(i + 1, j + 1), count);
                }
                return false;
            }
        }
        return true;
    }
}